#include "foregroundscene.h"
#include "mainwindow.h"
#include <QPainter>
#include "gameanimation.h"

/*

  SCENE SENSOR CLASS
  USED TO BIND WHOLE SCENE MOUSE ACTION
  */

SceneSensor::SceneSensor(QGraphicsObject *parent)
    :QGraphicsObject(parent)
{
    connect(this, SIGNAL(pressed()), this, SLOT(deleteLater()));
}


QRectF SceneSensor::boundingRect() const{
    int width = MainWindow::SCENE_WIDTH;
    int height = MainWindow::SCENE_HEIGHT;
    return QRectF(-width/2, -height/2, width, height);
}

void SceneSensor::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
}

void SceneSensor::mousePressEvent(QGraphicsSceneMouseEvent *event){
    emit pressed();
}

/*

  FOREGOURND SCENE CLASS

  */



ForegroundScene::ForegroundScene(QGraphicsObject* parent)
    :QGraphicsObject(parent)
{
    setVisible(false);
    setOpacity(0.5);
}


QRectF ForegroundScene::boundingRect() const{
    int width = MainWindow::SCENE_WIDTH;
    int height = MainWindow::SCENE_HEIGHT;
    return QRectF(-width/2, -height/2, width, height);
}

void ForegroundScene::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
    painter->fillRect(boundingRect(), Qt::black);
}


/*

  Input Blocker CLASS

  */

InputBlocker::InputBlocker(QGraphicsItem *parent)
    :QGraphicsObject( parent )
{
    setAcceptsHoverEvents( true );
    _w = 5000;
    _h = 5000;
    setVisible( false );
    setOpacity( 0.6 );
}
QRectF InputBlocker::boundingRect() const
{
    return QRectF( -_w/2, -_h/2, _w, _h );
}

void InputBlocker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->fillRect( -_w/2, -_h/2, _w, _h, Qt::black );
}

void InputBlocker::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    // an event holder.
}
